package cn.com.frame.commom.web;


import lombok.Data;

/**
 *
 * code
 *
 OK("成功",1),FAIL("失败",-1),NOT_ALLOW("无权限",-5),LOST_LOGIN("登录失效",-9);
 * 详细异常说明：EmRespCode 类
 */
@Data
public class RespData {
    /**
     * OK("成功",1),FAIL("失败",-1),NOT_ALLOW("无权限",-5),LOST_LOGIN("登录失效",-9);
     */
    private int code;
    /**
     * 消息
     */
    private String msg;

    private Object body;

    /**
     * 默认成功
     * @param body
     */
    public RespData(Object body){
        setCode(EmRespCode.OK.getValue());
        setMsg(EmRespCode.OK.getName());
        setBody(body);
    }

    /**
     * 自定义错误 返回无内容
     * @param emRespCode
     * @param msg
     */
    public RespData(EmRespCode emRespCode, String msg){
        setCode(emRespCode.getValue());
        setMsg(msg);
    }

    public RespData(EmRespCode emRespCode, String msg, Object body){
        setCode(emRespCode.getValue());
        setMsg(msg);
        setBody(body);
    }

}
